'use strict';

goog.provide('Blockly.Arduino.tts');
goog.require('Blockly.Arduino');
Blockly.Arduino.forBlock['tts_init'] = function(block) {
    Blockly.Arduino.definitions_['include_ESP32TTS'] = '#include <TTS_ESP.h>';
    var serialPort = block.getFieldValue('SERIAL_PORT');
    Blockly.Arduino.definitions_['object_ESP32TTS'] = `TTS_ESP TTS(&${serialPort});`;
    Blockly.Arduino.setups_['setup_ESP32TTS'] = `TTS.begin(115200);`;
    var code = ``;
    return code;
};
Blockly.Arduino.forBlock['tts_setTTSParameters'] = function(block) {
    var setDown = block.getFieldValue('SET_DOWN');
    var number = block.getFieldValue('TTS_NUMBER');
    var code = `TTS.setTTSParameters("${setDown}",${number});\n`;
    return code;
};
Blockly.Arduino.forBlock['tts_speek'] = function(block) {
    var text = Blockly.Arduino.valueToCode(block, 'TTS_TXT', Blockly.Arduino.ORDER_ASSIGNMENT) || '""';
    var code = `TTS.speak(${text});\n`;
    return code;
};
Blockly.Arduino.forBlock['tts_speekRingtones'] = function(block) {
    var text = block.getFieldValue('tts_Ringtones');
    var code = `TTS.speak("${text}");\n`;
    return code;
};